﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Streambolics
{
    public static class ExceptionExtensions
    {
        public static Exception Deepest (this Exception e)
        {
            while (e.InnerException != null)
            {
                e = e.InnerException;
            }
            return e;
        }

        public static string FullMessage (this Exception e)
        {
            string sep = "--------------------------------------------------------------------";

            StringBuilder sb = new StringBuilder ();
            sb.AppendLine (e.Message);

            while (e != null)
            {
                sb.AppendLine (sep);
                sb.AppendLine (e.Message);
                sb.AppendLine (e.StackTrace);
                e = e.InnerException;
            }
            return sb.ToString ();
        }
    }
}
